package com.qiuling.iot.mapper;

import com.qiuling.iot.entity.EquipmentInfo;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;

import java.util.List;

@Mapper
public interface EquipmentInfoMapper {
    int deleteByPrimaryKey(String id);

    int insert(EquipmentInfo record);

    int insertSelective(EquipmentInfo record);

    EquipmentInfo selectByPrimaryKey(String id);

    int updateByPrimaryKeySelective(EquipmentInfo record);

    int updateByPrimaryKey(EquipmentInfo record);

    /**
     * ----------------------------以下为自定义接口---------------------------------
     */
    List<EquipmentInfo> selectAll(String userId);

    /**
     * @description 维护新的层级关系
     * </br>
     * @param oldStr
     * @param newStr
     * @param relationCode
     * @return int
     * @author zhangqiang
     * @date 1:50 2020/2/14
     */
    int updateRelationCode(@Param("oldStr") String oldStr, @Param("newStr") String newStr,
                           @Param("relationCode") String relationCode);

    List<String> selectChildIds(String relationCode);

    int deleteEquipments(@Param("list") List<String> list);

    List<EquipmentInfo> selectEqupmentByIds(List<String> ids);

    /**
     * @description  根据设备id和用户id查询设备
     * </br>
     * @param id
     * @param userId
     * @return com.qiuling.iot.entity.EquipmentInfo
     * @author zhangqiang
     * @date 17:24 2020/2/18
     */
    EquipmentInfo getEquipmentInfoByUserIdAndEquiptmentId(@Param("id") String id, @Param("userId") String userId);
}